<?php
namespace jy_renwushop;
defined('BY_JYA') or exit('error');
/*
	任务
*/
class task extends \plugin{
	/*
		任务过期
	*/
	public function orderup(){
		$orders = $this->pdo_getall('renwuorder',array('status'=>0,'createtime <='=>time()-3600,'uniacid'=>$_SESSION['uniacid']));
		foreach($orders as $item){
			$renwu = $this->pdo_get('renwu',array('id'=>$item['renwuid'],'uniacid'=>$_SESSION['uniacid']));
			$time=time()-$this->hours_typetime[$item['hours_type']];
			if($item['createtime']<$time){
				$this->pdo_update('renwuorder',array('status'=>4),array('id'=>$item['id'],'uniacid'=>$_SESSION['uniacid']));
			}
		}
		return true;
	}
	public function orderupone($renwu){
		$time=time()-$this->hours_typetime[$renwu['hours_type']];
		$this->pdo_update('renwuorder',array('status'=>4),array('createtime <='=>$time,'status'=>0,'renwuid'=>$renwu['id'],'uniacid'=>$_SESSION['uniacid']));
		return true;
	}
	/*
		测试升级
	*/
	public function test(){		
		$order=pdo_get('jy_renwushop_renwuorder',array('id'=>3,'uniacid'=>$_SESSION['uniacid']));
		$this->model('renwu')->canfen($order);
	}
}